package cn.xxy.result;

import cn.xxy.ResultSetHandler;
import cn.xxy.RowProcessor;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

/**
 * @author xxy
 * @date 2021/7/29
 */
public class BeanListHandler<T> extends  org.apache.commons.dbutils.handlers.AbstractListHandler<T> implements ResultSetHandler<List<T>> {

    private final Class<T> beanClass;

    public BeanListHandler(Class<T> beanClass) {
        this.beanClass = beanClass;
    }

    @Override
    public T handleRow(ResultSet rs) throws SQLException {
        return RowProcessor.toBean(rs, beanClass);
    }
}
